package com.yixun.qfbao.hander;

import com.yixun.qfbao.util.exception.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.ResetPwdReqDto;
import com.yixun.qfbao.apidto.ResetPwdResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.ResetPwdReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * Created by Administrator on 2017/11/21.
 */
@Service("resetPwdHander")
public class ResetPwdHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(ResetPwdHander.class);
	@Autowired
	PersonnelService personnelService;
	
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		ResetPwdReqVo req = (ResetPwdReqVo)reqDto;
		ResetPwdReqDto resetPwdReqDto = req.getParams();
		BaseResponseDTO<ResetPwdResDto> res = new BaseResponseDTO<ResetPwdResDto>();
		ResetPwdResDto resDto = new ResetPwdResDto();
		try {
			resDto = personnelService.resetPwd(resetPwdReqDto);
		}catch (TException t) {
			t.printStackTrace();
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg(t.getErrorMsg());
		} catch(Exception e) {
			logger.error("ResetPwdHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("重置失败!");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
}
